package com.yyi.springcloud.controller;


import com.yyi.springcloud.entities.CoordonateInfoModel;
import com.yyi.springcloud.entities.CoordonateVo;
import com.yyi.springcloud.service.Local_CoordonateInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/mysqlapi/CoordonateInfoApi")
public class Mysql_CoordinateInfoController {
	@Resource
	private Local_CoordonateInfoService coordonateInfoService;

	/**
	 * 1.根据primarykey获取坐标系信息
	 * @param primaryKey
	 * @return
	 */
	//http://localhost:8080/bxxs/api/CoordonateInfoApi/getCoordonate?primarykey=2015-12-1607:22:321
	@ResponseBody
	@RequestMapping(value = "/getCoordonate", method = RequestMethod.GET)
	public List<CoordonateVo> getInfo(String primaryKey) {
		CoordonateInfoModel coordonateInfoModel=new CoordonateInfoModel();
		coordonateInfoModel.setPrimarykey(primaryKey==""?null:primaryKey);
		return coordonateInfoService.selectCoordonate(coordonateInfoModel);
	}

	/**
	 * 2.根据primaryKey和coordinateno更新坐标系信息
	 * @param primarykey
	 * @param coordinateno
	 * @return
	 */
	//http://localhost:8080/bxxs/api/CoordonateInfoApi/updateCoordonateInfo?primarykey=2017-11-1611:17:211&coordinateno=2
	// &highvalue=1&lowvalue=1
	@ResponseBody
	@RequestMapping(value = "/updateCoordonateInfo", method = RequestMethod.GET)
	public String updateCoordonateInfo(String primarykey,String coordinateno,Integer highvalue,Integer lowvalue) {
		int result = coordonateInfoService.updateCoordonateInfo(primarykey, coordinateno,highvalue,lowvalue);
		if(result==1){
			return "success";
		}else{
           return "fail";
		}
	}
}
